using System;
using System.Collections.Generic;
using System.Text;

using NHibernate;
using Framework.Library.Domain;
using Framework.Library.Base;

namespace Framework.Library.DAO
{
    public partial interface IPortalModulesettingManager : IManagerBase<PortalModulesetting, string>
    {
		// Get Methods
		PortalModulesetting GetById(System.Int32 moduleID, System.String settingName);
    }

    partial class PortalModulesettingManager : ManagerBase<PortalModulesetting, string>, IPortalModulesettingManager
    {
		#region Constructors
		
		public PortalModulesettingManager() : base()
        {
        }
        public PortalModulesettingManager(INHibernateSession session) : base(session)
        {
        }
		
		#endregion
		
        #region Get Methods

		public override PortalModulesetting GetById(string id)
		{
			string[] keys = id.Split('^');
			
			if(keys.Length != 2)
				throw new Exception("Invalid Id for PortalModulesettingManager.GetById");
			
			return GetById(System.Int32.Parse(keys[0]), keys[1].ToString());
		}
		public PortalModulesetting GetById(System.Int32 moduleID, System.String settingName)
		{
			ICriteria criteria = Session.GetISession().CreateCriteria(typeof(PortalModulesetting));
			
			criteria.Add(NHibernate.Criterion.Expression.Eq("ModuleID", moduleID));
			criteria.Add(NHibernate.Criterion.Expression.Eq("SettingName", settingName));
			
			PortalModulesetting result = (PortalModulesetting)criteria.UniqueResult();

            if (result == null)
                throw new NHibernate.ObjectDeletedException("", null, null);

            return result;
		}
		
		
		#endregion
    }
}